Repository navigation
feat(service-knowledge): record changes sync through the queue service — a save does not wait for the embedder, a failed sync is retried, a rolled-back write is never indexed - #38043
Conversation
…ependencies Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
…e (wip) Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
…otocol, the RAG guide and the README Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
…e it was Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
…ps dead letters Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
…nd the queue service from source Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
…umn requires Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
…ted yet; test the published rows, not their absence Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
… and by record Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
📓 Docs Drift CheckThis PR changes 1 package(s): 34 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 6 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 4 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 711f6b613c7e2b32c49c31d5669ab1c18cb77c78 && git checkout 711f6b613c7e2b32c49c31d5669ab1c18cb77c78
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 8d34c4404f951410083a6caebd6ad8003ea3423d 5d430ea461542902c21fbc9ff0c6ec921d07c758 && git checkout -B drift-repro 8d34c4404f951410083a6caebd6ad8003ea3423d && git merge --no-ff 5d430ea461542902c21fbc9ff0c6ec921d07c758
node scripts/docs-audit/affected-docs.mjs --json 8d34c4404f951410083a6caebd6ad8003ea3423d
|
|
repo:objectstack#1 · os-elon-musk · session_016WV4czzx9dtSEm3jWWL9c3 Contract reviewServed-tier: Face: declaration. The diff touches no published-schema path and no governed rule text (13 files, all under ① Derived judgments
② Semver level
③ Boundary flags
Nits (no grade)
No must-fix, no should-fix. Implemented-by: VERDICT: PASS |
|
repo:objectstack#1 · os-elon-musk · session_016WV4czzx9dtSEm3jWWL9c3 L1 review — ACCEPT on merits, landing blocked by the PR-body guardHead: Verdict: ACCEPT on the code, tests and docs at this head. Contract review: TIER_DEFAULT declaration record 7227410375, PASS, no must-fix and no should-fix. Read: the queue module, the service and plugin changes, the hooks, the 20 new tests, the changeset and both docs pages sentence by sentence. The publish goes through Before it lands:
A head that moves only for the claim and a re-run needs nothing more from this lane; a code change needs a delta read. Nits (optional, may go in a follow-up): N1 qualify the "last committed version" sentence in |
|
repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP Landing · area o1-C · head
State: ready + auto-merge; #37735 and #37110 close on merge via |
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
…h the source's binding Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
⛔ merge queue 构建失败 — 先分诊,再决定要不要重排队列构建 46064910619 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集), 分类: 失败的 job(日志抽取,best effort):
跨 PR 相同签名(24h,按失败测试文件聚合):
历史信号:
分诊清单:
Generated by Claude Code · merge-queue-triage workflow (#4859) |
|
repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP Merge-queue drop (CI_FAILURE): cause and fix Cause: this was a real semantic conflict with main, not a flake. #38026 landed on main and made Fix (commit 5d430ea, on top of a merge of origin/main):
The verification readings are in the dev report. Generated by Claude Code |
repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP
Fixes #37735
Fixes #37110
Clause-②: yes (widening) —
KnowledgeServicePluginOptionsgains the optionalrecordSyncRetry;KnowledgeServicegainsrouteRecordSyncs,recordSyncQueued,enqueueRecordSyncandprocessRecordSync; the package exportsKNOWLEDGE_RECORD_SYNC_QUEUE,RECORD_SYNC_RETRY_DEFAULTSand theKnowledgeRecordSync*typesMetadata-protocol: none
维护者速读
What changes
A record change of an indexed object no longer syncs its document inside the write. Where the kernel composes a durable
queueservice (QueueServicePluginover a data engine) and a data engine is bound, both triggers publish to theknowledge-record-syncqueue:knowledge-event-syncsubscription;A worker, subscribed in
kernel:ready, re-reads the row and writes or removes the document. Everything else keeps the inline path and says so once at boot atwarn:listFailed;enableEventSync: falseandrefresh.onRecordChange: falseare unchanged: they publish nothing.{ source, object, recordId, reason }, where the reason iseventorfreshness. It never carries a field value. The test reads the storedsys_job_queuerow.runAfterOpenUnitsCommit. It goes out once the open unit commits (the write's own unit or a caller'sengine.transaction()) and is dropped on rollback. With no unit open it goes out at once. I did not use the other approach (the queue row joining the write's unit), and no engine change was needed.idempotencyKey.DbQueueAdaptersuppresses a keyed publish while a message is pending or running, and for 24 h after it completes. A key per document would therefore drop a save made while that record's sync runs, and every save of it for a day after. Each worker run re-reads the row, so the last committed version wins.IQueueServiceandDbQueueAdapterare unchanged.recordSyncRetry: by default 8 attempts, 5 s doubling to a 2 min cap. The message then becomes alistFaileddead letter that names the source and record, logged once aterror.repairStalenow publishes afreshnessmessage instead of starting an un-awaited inline sync.freshnessmessage inrepairStale). If fix(service-knowledge)!: retire the knowledge field gate's title arm behind a per-source recipe proof #37963 lands first, this branch merges main and adopts its seam.content/docs/protocol/knowledge.mdxgains "Through the queue" and "Without a durable queue".content/docs/ai/knowledge-rag.mdx, the README and a changeset are updated too.Tests
src/__tests__/record-sync-queue.test.tsis new. It boots a realObjectKernelwithObjectQLPlugin,SqlDriver(a better-sqlite3 file),QueueServicePlugin({ adapter: 'db' })andKnowledgeServicePlugin. Every queue-path case runs once per trigger (realtime, and the hooks).The queue-path cases cover:
engine.transaction();Further cases:
afterInserthook that aborts the write's own unit publishes nothing;warnand inline sync, plus both switches;destroy()leaves the message pending.All runs were taken under
os-verify-lock, on head 43dc682 unless noted:pnpm --filter @objectstack/service-knowledge exec vitest run --maxWorkers=2: 19 of 19 files and 593 of 593 tests pass (on merge head 640b356; the one later commit changes only docs and the changeset);pnpm --filter @objectstack/service-knowledge typecheck:check:test-typecheck: OK.Ablations (mutated on disk, test file re-run, restored with git checkout; tests run from source, so no rebuild)
runAfterOpenUnitsCommitremoved, publish at once): 4 failed. They are the rolled-back insert (both triggers), the own-unit test and the own-unit abort. The caller-transaction case stayed green under this mutation, because on SQLite's single connection the poller cannot read inside an open transaction. The rollback cases are the pin for the deferral.idempotencyKey= source:object:recordId): 9 failed, including the burst, after-completed and delete cases.titleadded to the message on both triggers): 2 failed (the identifiers-only case for each trigger).warndropped: 2 failed.listFailedaccepted: 2 failed.Acceptance notes
MemoryQueueAdapter(adapter: 'memory') carries nodegradedlabel and has nolistFailed. It is refused through thelistFailedcondition, so it takes the inline path with the boot warn.chainAfterper document) orders two runs on one node. Two nodes processing two messages for one record are not ordered against each other. Each run re-reads the row, so the last run to finish writes what it read. A save committing between one node's read and another's write can leave an older version until the next save, a freshness hit or the reconcile.runAfterOpenUnitsCommitsees the open unit). A realtime adapter that delivers out of process would publish with no unit open, that is at once. That is still after the write returned, but not ordered against a caller's transaction. No such adapter ships today.granularity: 'record'searches do not; the docs now say so.queueon every preset exceptminimal. Underminimalthe sync takes the inline path with the warn.Verification
Two-minute check:
pnpm --filter @objectstack/service-knowledge exec vitest run --maxWorkers=2 src/__tests__/record-sync-queue.test.tsExpected result: 33 of 33 tests pass.
Read first (by risk):
knowledge-service.ts:publishRecordSyncs(the commit deferral) andprocessRecordSync(what is retried and what completes).knowledge-service-plugin.ts:startRecordSyncQueue(the queue resolution, the fallback warn and the dead-letter line).knowledge-record-sync-queue.ts:recordSyncPublishOptions(why there is no idempotency key).Local gate subset
dispatch-gates --commands --repo objectstack-ai/objectstackderived 119 families. The--ranreconciliation reads: 115 run, 3 NOT MEASURED, 1 unrun.check:skill-examples,check:dual-build-cjs-loads,check:published-readme-exports.check:published-readme-exports, I confirmed the one new README import (QueueServicePluginfrom@objectstack/service-queue) by hand againstservice-queue/dist/index.d.ts.@objectstack/spec check:docs:packages/spec/json-schemais older thansrc. This branch touches nothing in spec.check:dts-closure:packages/rest/disthas no.d.ts. This branch does not touch rest; the partial dist likely comes from a build I stopped earlier.check:type-check-debt, because it builds every package under the shared lock.CI measures the full set.
overlap-checkon 43dc682:VERDICT clean exit 0against main and 6 open PRs (#38038, #38037, #38032, #38026, #37982, #37963).Generated by Claude Code